<template>
	<view class="container">
		<up-radio-group v-model="value" placement="column" iconPlacement="right" borderBottom @change="radioChange">
			<up-radio :customStyle="{marginBottom: '8px',marginTop: '8px'}" v-for="(item, index) in list" :key="index"
				:label="item.name" :name="item.value">
			</up-radio>
		</up-radio-group>
	</view>
</template>
<script>

	import {
		onLoad,
		onUnload
	} from "@dcloudio/uni-app"
	import {
		reactive,
		toRefs,
		ref,
	} from "vue"
	export default {

		setup() {
			const state = reactive({

				list: [{
					value: 0,
					name: '每小时'
				}, {
					value: 1,
					name: '每半天'
				}, {
					value: 2,
					name: '每天'
				}, {
					value: 3,
					name: '每晚'
				}, {
					value: 4,
					name: '每周'
				}, {
					value: 5,
					name: '每月'
				}, {
					value: 6,
					name: '每次'
				}, {
					value: 7,
					name: '每个'
				}, {
					value: 8,
					name: '每套'
				}, {
					value: 9,
					name: '每台'
				}, {
					value: 10,
					name: '每分钟'
				}, {
					value: 11,
					name: 'KG'
				}, {
					value: 12,
					name: '吨'
				}, {
					value: 13,
					name: '斤'
				}, {
					value: 14,
					name: '米'
				}, {
					value: 15,
					name: 'KM'
				}, {
					value: 16,
					name: 'M'
				}, {
					value: 17,
					name: '课时'
				}, ],
				value: '',
			})


			onLoad((option) => {
				if (option.priceTypeId) {
					state.value = Number(option.priceTypeId)
				}
				
			})
			const radioChange = (value) => {
				let arr = state.list.filter((item) => item.value === value)
				if (arr.length > 0) {
					uni.$emit('getPriceType', arr[0])
					uni.navigateBack(-1)
				}

			}
			const getData = async () => {
				const {
					data
				} = await categoryListApi()
				state.list = data
			}
			return {
				...toRefs(state),
				radioChange,
			}
		}
	}
</script>

<style>
	.container {
		background: #fff;
		margin-top: 10rpx;
		padding: 20rpx;
	}
</style>